package assignment

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer("api/v2/onlineLanguageQuizzes/submissions/\\d+/students/tasks/\\d+/assignments/\\d+/quizzes/\\d+/runningLog"),
                producer("api/v2/onlineLanguageQuizzes/submissions/0/students/tasks/1/assignments/1/quizzes/1/runningLog"))
        headers {
            contentType(applicationJsonUtf8())
            header('id', 1)
        }
    }
    response {
        status(200)
        body("""
            {
                "id":1,
                "assignmentId":1,
                "quizId":1,
                "userId":1,
                "userAnswer":"asdas",
                "submitTime":12345678,
                "status":2,
                "result":"SUCCESS",
                "answerLanguage":"java",
            }
            """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.userId', byRegex(number()))
            jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$.submitTime', byRegex("[\\s\\S]+"))
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.result', byRegex("[\\s\\S]+"))
            jsonPath('$.answerLanguage', byRegex("[\\s\\S]+"))
        }
    }
}